package jmine.tec.hydra.script.impl;

import jmine.tec.hydra.api.HydraMessage;
import jmine.tec.hydra.script.FilterScriptContext;
import jmine.tec.script.persistent.context.impl.AbstractScriptExecutionContext;

/**
 * Contexto de execução de scripts de filtro.
 * 
 * @author lundberg
 */
public class FilterScriptContextImpl extends AbstractScriptExecutionContext<HydraMessage> implements FilterScriptContext {

    private static final String HYDRA_MESSAGE = "hydraMessage";

    /**
     * Define a mensagem hydra que deve ser filtrada.
     * 
     * @param hydraMessage hydraMessage
     */
    private void setHydraMessage(HydraMessage hydraMessage) {
        this.getParameters().putParameter(HYDRA_MESSAGE, hydraMessage);
    }

    /**
     * {@inheritDoc}
     */
    public HydraMessage getResult() {
        return (HydraMessage) this.getParameters().getParameterValues().get(HYDRA_MESSAGE);
    }

    /**
     * {@inheritDoc}
     */
    public String getTracer() {
        return "";
    }

    /**
     * {@inheritDoc}
     */
    public FilterScriptContext prepare(HydraMessage hydraMessage) {
        this.setHydraMessage(hydraMessage);
        return this;
    }
}
